import request from '@/utils/request'
const categoryBaseURL = '/posts/category'
const postsBaseURL = '/posts'
const cardBaseURL = '/posts/card'
export default {
  // 获得职位分类列表
  getCategoryList() {
    return request({
      url: categoryBaseURL + '/list',
      method: 'GET'
    })
  },
  // 获得招聘信息的卡片详情
  getPostsCardInfo(categoryId, num = 9) {
    return request({
      url: postsBaseURL + '/card',
      method: 'GET',
      params: {
        categoryId,
        num
      }
    })
  },
  // 保存招聘职位
  savePosts(data) {
    return request({
      url: postsBaseURL + '/save',
      method: 'POST',
      data
    })
  },
  // 获得职位卡片信息
  getCardInfo(page, size) {
    return request({
      url: cardBaseURL + '/info',
      method: 'GET',
      params: {
        page,
        size
      }
    })
  },
  // 根据id获得posts信息
  getPostsInfo(data) {
    return request({
      url: postsBaseURL + '/info',
      method: 'POST',
      data
    })
  },
  // 根据companyId获得职位
  getByCompanyId(companyId) {
    return request({
      url: postsBaseURL + '/getByCompanyId',
      method: 'GET',
      params: {
        companyId
      }
    })
  },
  getByCompanyIdAndPage(companyId, page, size) {
    return request({
      url: postsBaseURL + '/getByCompanyId/page',
      method: 'GET',
      params: {
        companyId,
        page,
        size
      }
    })
  },
  getByUserIdByPage(userId, page, size) {
    return request({
      url: postsBaseURL + '/getByUserId/page',
      method: 'GET',
      params: {
        userId,
        page,
        size
      }
    })
  }
}
